import {createStore} from "redux";
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import {Reducer} from './reducer';

const persistConfig = {
    key: 'root',
    storage,
    whitelist: ['userId','userName','nickName','token','cId','friendList','chatList']
}

const persistedReducer = persistReducer(persistConfig, Reducer)

export const store = createStore(persistedReducer,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());

export const persistor = persistStore(store);